﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace nb.development.csmediamanager
{
    public partial class Quality : Form
    {
        public Quality(imagemode quality, int jpgquality)
        {
            InitializeComponent();
            qualityBar.Value = jpgquality;
            if (quality == imagemode.JPG) { radioButton1.Checked = true; groupBox1.Enabled = true; }
            else { radioButton2.Checked = true; groupBox1.Enabled = false; }
            groupBox1.Text = "Quality " + jpgquality;
        }

        public event QualityChangeHandler QualityChanged;

        public int JPGQuality { get { return qualityBar.Value; } }
        public imagemode QualityMode { get { return radioButton1.Checked ? imagemode.JPG : imagemode.PNG; } }

        private void radioButton1_Click(object sender, EventArgs e)
        {
            groupBox1.Enabled = radioButton1.Checked;
            if (QualityChanged != null) QualityChanged();
        }

        private void qualityBar_ValueChanged(object sender, EventArgs e)
        {
            if (QualityChanged != null) QualityChanged();
            groupBox1.Text = "Quality " + qualityBar.Value;
        }
    }
    public delegate void QualityChangeHandler();
    public enum imagemode { JPG, PNG };
}
